<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %><%--
  Created by IntelliJ IDEA.
  User: WIzarder
  Date: 2021/5/30
  Time: 16:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--1、声明类属性--%>
    <%!
        private Integer id;
        private String name;
        private static Map<String,Object> map;
    %>
<%--2、声明 static 静态代码块--%>
    <%!
        static {
            map = new HashMap<>();
            map.put("key1","value1");
            map.put("key2","value2");
        }
    %>
<%--3、声明类方法--%>
    <%!
            public int sum(int a,int b){
                return a+b;
            }
    %>
<%--4、声明内部类--%>
    <%!
        private class AA{
            private String numberName = "AA";
            private int numberAge = 44;
        }
    %>
<%--练习：
1.输出整型
2.输出浮点型
3.输出字符串
4.输出对象    --%>
    <%=15%><br/>
    <%=13.14%><br/>
    <%="我爱你！"%><br/>
    <%=map%><br/>
    <%=request.getParameter("username")%><br/>
<%--练习：--%>
<%--1.代码脚本----if 语句--%>
    <%
        String useranme = request.getParameter("username");
        if("luhu".equals(useranme)){%>
            <%="用户名为：" + useranme%>
    <% } else{%>
        <%="用户名错误！"%>
    <%}%>
<%--2.代码脚本----for 循环语句--%>
    <table border="1px" cellspacing="0">
    <%
        for (int i = 0; i < 10; i++) {%>
        <tr>
            <td>第<%=i+1%>行</td>
        </tr>
     <%   }%>
<%--3.翻译后 java 文件中_jspService 方法内的代码都可以写--%>
        <%
            String username = request.getParameter("username");
            System.out.println("请求参数username=" + username );
        %>
    </table>
</body>
</html>
